package ai.people.netmon.framework.domain.common.monitor;

import ai.people.netmon.framework.businessenum.AnalysisSourceEnum;
import ai.people.netmon.framework.domain.ethereum.monitor.entity.EthereumUsers;
import ai.people.netmon.framework.domain.facebook.view.entity.FacebookAccountView;
import ai.people.netmon.framework.domain.reddit.monitor.entity.RedditUsers;
import ai.people.netmon.framework.domain.twitter.monitor.entity.TwitterMonitorUsers;
import ai.people.netmon.framework.domain.twitter.view.entity.TwitterAccountView;
import ai.people.netmon.framework.domain.weibo.monitor.entity.WeiboUsers;
import ai.people.netmon.framework.domain.whatsapp.monitor.entity.WhatsappUsers;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * 监测-用户信息（前端要求的格式）
 *
 * @author zhenglin
 * @since 2022/3/15
 */
@Data
@NoArgsConstructor
public class MonitorUsersVO {
    /**
     * 账号id
     */
    private String id;
    /**
     * 账号类型
     */
    private String analysisSource;
    /**
     * 头像链接
     */
    private String avatar;
    /**
     * 名
     */
    private String firstName;
    /**
     * 姓
     */
    private String lastName;
    /**
     * 账号
     */
    private String username;
    /***
     * 群组数量
     */
    private Integer groupCount;
    /**
     * 手机号
     */
    private String phone;
    /**
     * 地址
     */
    private String location;
    /**
     * 标签
     */
    private String tags;
    /**
     * 描述
     */
    private String description;

    public MonitorUsersVO(FacebookAccountView one) {
        this.id = one.getAccountId();
        this.analysisSource = AnalysisSourceEnum.facebook.name();
        this.avatar = one.getHeaderPicture();
        this.firstName = null;
        this.lastName = null;
        this.username = one.getAccountName();
        this.groupCount = null;
        this.phone = one.getFormattedPhoneNumber();
        this.location = one.getAddress();
        this.tags = null;
        this.description = one.getDescription();
    }

    public MonitorUsersVO(TwitterMonitorUsers one) {
        this.id = one.getUserId();
        this.analysisSource = AnalysisSourceEnum.twitter.name();
        this.avatar = one.getHeaderPicture();
        this.firstName = one.getNickName();
        this.lastName = one.getNickName();
        this.username = one.getUserName();
        this.groupCount = null;
        this.phone = one.getFormattedPhoneNumber();
        this.location = one.getAddress();
        this.tags = null;
        this.description = one.getDescription();
    }

    public MonitorUsersVO(TwitterAccountView one) {
        String accountId = one.getAccountId();
        this.id = accountId;
        this.analysisSource = AnalysisSourceEnum.twitter.name();
        this.avatar = one.getHeaderPicture();
        this.firstName = null;
        this.lastName = null;
        String accountName = one.getAccountName();
        this.username = accountName;
        if (StringUtils.isBlank(accountId)){
            this.id = accountName;
        }
        this.groupCount = null;
        this.phone = one.getFormattedPhoneNumber();
        this.location = one.getAddress();
        this.tags = null;
        this.description = one.getDescription();
    }

    public MonitorUsersVO(RedditUsers one) {
        this.id = one.getUserId();
        this.analysisSource = AnalysisSourceEnum.reddit.name();
        this.avatar = one.getHeaderImage();
        this.firstName = null;
        this.lastName = null;
        this.username = one.getUserName();
        this.groupCount = null;
        this.phone = null;
        this.location = null;
        this.tags = null;
        this.description = one.getDescription();
    }

    public MonitorUsersVO(EthereumUsers one) {
        this.id = one.getId();
        this.analysisSource = AnalysisSourceEnum.ethereum.name();
        this.avatar = null;
        this.firstName = null;
        this.lastName = null;
        this.username = one.getName();
        this.groupCount = null;
        this.phone = null;
        this.location = null;
        this.tags = null;
        this.description = null;
    }

    public MonitorUsersVO(WeiboUsers one) {
        this.id = String.valueOf(one.getUserId());
        this.analysisSource = AnalysisSourceEnum.weibo.name();
        this.avatar = null;
        this.firstName = null;
        this.lastName = null;
        this.username = one.getName();
        this.groupCount = null;
        this.phone = null;
        this.location = null;
        this.tags = null;
        this.description = null;
    }

    public MonitorUsersVO(WhatsappUsers one) {
        this.id = one.getId();
        this.analysisSource = AnalysisSourceEnum.weibo.name();
        this.avatar = null;
        this.firstName = null;
        this.lastName = null;
        this.username = one.getName();
        this.groupCount = null;
        this.phone = null;
        this.location = null;
        this.tags = null;
        this.description = null;
    }


}
